﻿using System;
using nRoute.Components.Composition;
using nRoute.Utilities;

namespace nRoute.Mapping
{
    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = true, Inherited = false)]
    public class MapNavigationFileAttribute
        : MapNavigationBaseAttribute
    {
        private readonly string _filePath;

        public MapNavigationFileAttribute(string url, string filePath)
            : base(url)
        {
            Guard.ArgumentNotNullOrWhiteSpace(filePath, "filePath");
            _filePath = filePath;
        }

        protected string FilePath
        {
            get { return _filePath; }
        }

        protected internal override IResourceLocator GetResourceLocator(Type targetType, ITypeBuilder typeBuilder)
        {
            return new DefaultNavigationFileLocator(base.Url, this.FilePath);
        }
    }
}
